<?php

use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use App\Http\Controllers\scheduleController\ScheduleController; 
use App\Http\Controllers\scheduleController\ScheduleTaskController;

// Schedule::call(function () {
//     // 检查任务是否被锁定
//     if (! Cache::has('schedule-daily-task-at-10-00')) {
//         Log::info('我是任务调度路由');
//     }

// })->name('daily-task-at-10-00')
//     ->everySecond()
//     ->timezone('Asia/Shanghai')
//     ->withoutOverlapping();

// Schedule::call(function () {
//     // 检查任务是否被锁定
//     if (! Cache::has('schedule-daily-task-at-10-00')) {
//         Log::info('我是任务调度路由');
//     }
    
// })->name('daily-task-at-10-00')
//     ->cron('* * * * *')
//     ->timezone('Asia/Shanghai')
//     ->withoutOverlapping();

    

Route::prefix('api/schedule')->group(function () {
    Route::get('/stopTask', [ScheduleController::class, 'stopTask']);  // 设置任务锁定，有效期为24小时
    Route::get('/resumeTask', [ScheduleController::class, 'resumeTask']); // 恢复定时任务
    Route::get('/checkTaskStatus', [ScheduleController::class, 'checkTaskStatus']); // 检查任务状态
});

// 调度任务管理API
Route::prefix('api/schedule-tasks')->group(function () {
    Route::get('/', [ScheduleTaskController::class, 'index']);
    Route::post('/', [ScheduleTaskController::class, 'store']);
    Route::get('/{id}', [ScheduleTaskController::class, 'show']);
    Route::put('/{id}', [ScheduleTaskController::class, 'update']);
    Route::delete('/{id}', [ScheduleTaskController::class, 'destroy']);
    Route::patch('/{id}/toggle-status', [ScheduleTaskController::class, 'toggleStatus']);
});